package com.liangzhong.facade
{
	import com.liangzhong.constants.ApplicationConstants;
	import com.liangzhong.controller.StartupCommand;
	import com.liangzhong.facade.activity.ActivityFacade;
	import com.liangzhong.facade.bag.BagFacade;
	import com.liangzhong.facade.chat.ChatFacade;
	import com.liangzhong.facade.shop.ShopFacade;
	import com.liangzhong.facade.user.UserFacade;
	import com.liangzhong.modules.Main.command.GameRoomCommand;
	import com.liangzhong.modules.Main.command.LobbyCommand;
	import com.liangzhong.modules.Main.command.LogicCommand;
	import com.liangzhong.modules.login.command.LoginCommand;
	import com.liangzhong.proxy.lobby.LobbyProxy;
	import com.liangzhong.proxy.login.LoginProxy;
	
	import org.puremvc.as3.patterns.facade.Facade;

	/**
	 * 主facade
	 * @author lxh
	 * 
	 */	
	public class GameFacade extends Facade
	{
		public static const STARTUP:String = "startup";
		public static var instance:GameFacade;
		
		public function GameFacade()
		{
			super();
		}
		
		public static function getInstance():GameFacade
		{
			if (instance == null)
			{
				instance = new GameFacade();
			}
			return instance as GameFacade;
		}
		
		override protected function initializeModel():void
		{
			super.initializeModel();
			
		}
		override protected function initializeView():void
		{
			super.initializeView();
		}
		override protected function initializeController():void
		{
			super.initializeController();
			
			//startup----appllication init
			this.registerCommand(STARTUP,StartupCommand);
			/******************************  Login   ***********************************************/
			this.registerCommand(ApplicationConstants.Login_TGW,LoginCommand);
			//登陆信息
			this.registerCommand(ApplicationConstants.Login_login,LoginCommand);
			this.registerCommand(LoginProxy.Login_Result,LoginCommand);
			//签到
			this.registerCommand(ApplicationConstants.Login_Get_SignInfo,LoginCommand);
			this.registerCommand(ApplicationConstants.Login_User_Sign,LoginCommand);
			this.registerCommand(ApplicationConstants.Login_User_Resign,LoginCommand);
			this.registerCommand(ApplicationConstants.Login_User_Get_Sign_Award,LoginCommand);
			//qzone award
			this.registerCommand(ApplicationConstants.Login_User_Get_Qzone_Vip_Award,LoginCommand);
			/******************************  公共   ***********************************************/
			this.registerCommand(ApplicationConstants.Public_Drop_Time,LogicCommand);
			this.registerCommand(ApplicationConstants.Public_Match_Get_Award,LogicCommand);
			this.registerCommand(ApplicationConstants.Public_Club_Get_Award_list,LogicCommand);
			/******************************* User  ********************************************/
			var userFacade :UserFacade = new UserFacade();
			userFacade.facade = this;
			userFacade.initializeController();
			/******************************  Lobby   ***********************************************/
			//用户基本信息
			this.registerCommand(ApplicationConstants.Lobby_getUserInfo,LobbyCommand);
			this.registerCommand(LobbyProxy.GetUserInfo_Result,LobbyCommand);
			//用户财富信息
			this.registerCommand(ApplicationConstants.Lobby_getUserFortune,LobbyCommand);
			this.registerCommand(LobbyProxy.GetUserFortune_Result,LobbyCommand);
			//游戏房间信息
			this.registerCommand(ApplicationConstants.Lobby_getGameRooms,GameRoomCommand);
			this.registerCommand(LobbyProxy.GetGameRooms_Result,GameRoomCommand);
			//在线房间人数
			this.registerCommand(ApplicationConstants.Lobby_getGameRoomNumbers,GameRoomCommand);
			this.registerCommand(LobbyProxy.GetGameRoomNumbers_Result,GameRoomCommand);
			//进入房间
			this.registerCommand(ApplicationConstants.Lobby_enterGameRoom,GameRoomCommand);
			this.registerCommand(LobbyProxy.EnterGameRoom_Result,GameRoomCommand);
			//坐下
			this.registerCommand(ApplicationConstants.Lobby_SitDown,GameRoomCommand);
			//离开房间
			this.registerCommand(ApplicationConstants.Lobby_leaveGameRoom,GameRoomCommand);
			this.registerCommand(LobbyProxy.leaveGameRoom_Result,GameRoomCommand);
			//通知用户离开房间 本人收到
			this.registerCommand(LobbyProxy.leaveGameRoomNotify_Result,LobbyCommand);
			//公告
			this.registerCommand(LobbyProxy.noticeNotify_Result,LobbyCommand);
			//好友添加通知
			this.registerCommand(LobbyProxy.addFriend_Result,LobbyCommand);
			//大厅聊天
			this.registerCommand(ApplicationConstants.Lobby_LobbyChat,LobbyCommand);
			this.registerCommand(LobbyProxy.Lobby_Chat_Result,LobbyCommand);
			//赢分公告
			this.registerCommand(LobbyProxy.Lobby_Win_Info_Result,LobbyCommand);
			/**********背包********/
			var bagFacade :BagFacade = new BagFacade();
			bagFacade.facade = this;
			bagFacade.initializeController();
			/*聊天*/
			var chatFacade:ChatFacade = new ChatFacade();
			chatFacade.facade = this;
			chatFacade.initializeController();
			//商城
			var shopFacade:ShopFacade = new ShopFacade();
			shopFacade.facade = this;
			shopFacade.initializeController();
			//活动
			var activityFacade:ActivityFacade = new ActivityFacade();
			activityFacade.facade = this;
			activityFacade.initializeController();
		}
		/**
		 *启动MVC，主程序中调用此方法
		 * 	* @param myApp 
		 */			
		public function startUp():void
		{
			this.sendNotification(STARTUP);
		}
	}
}